class_name ConditionUtil

## condition_func 检测方法
static var condition_func_dict = {
	None = {
		ConditionFunc = check_none_condition,
	},
}

#region Func
static func check_none_condition(condition_info,args:Dictionary = {}) -> bool:
	var entity = args.entity
	return true
#endregion

static func check_condition(condition,entity:Entity = null,args:Dictionary = {}) -> bool:
	args.entity = entity
	if typeof(condition) == TYPE_ARRAY:
		return _check_array_condition(condition,args)
	else:
		return _check_single_condition(condition,args)
static func _check_single_condition(condition_tag:String,args:Dictionary = {}) -> bool:
	if not condition_func_dict.has(condition_tag):
		push_error("[{0}]未在ConditionUtil中注册".format([condition_tag]))
		return false
	var condition_info = condition_func_dict[condition_tag]
	if "ConditionFunc" not in condition_info:
		push_error("Condition中没有ConditionFunc")
		return false
	return condition_info.condition_func.call(condition_info,args)

static func _check_array_condition(condition_tags,args:Dictionary = {}) -> bool:
	var res:bool = true
	for condition_tag in condition_tags:
		res = res and _check_single_condition(condition_tag,args)
	return res
